/*
 * task.c
 *
 *  Created on: 30/11/2010
 *      Author: wendell
 */

void switch_to_user_mode()
{

	// Set up a stack structure for switching to user mode.
	asm volatile("  \
			cli; \
			mov $0x23, %ax; \
			mov %ax, %ds; \
			mov %ax, %es; \
			mov %ax, %fs; \
			mov %ax, %gs; \
			\
			mov %esp, %eax; \
			pushl $0x23; \
			pushl %eax; \
			pushf; \
			pushl $0x1B; \
			push $1f; \
			iret; \
			1: \
			");
}
